{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b74c3d7c",
   "metadata": {},
   "source": [
    "# 206.反转链表\n",
    "\n",
    "[反转链表](https://leetcode.cn/problems/reverse-linked-list/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1a8fffea",
   "metadata": {},
   "outputs": [],
   "source": [
    "class ListNode:\n",
    "    def __int__(self,val:int =0,next=None):\n",
    "        self.val = val\n",
    "        self.next = next\n",
    "\n",
    "## 双指针法\n",
    "class Solution:\n",
    "    def reverseList(self,head:ListNode) -> ListNode:\n",
    "        cur = head\n",
    "        pre = None\n",
    "        while cur:\n",
    "            temp = cur.next\n",
    "            cur.next = pre\n",
    "            pre = cur\n",
    "            cur = temp\n",
    "        return pre\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "env_py38",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.8.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
